package com.appwoo.txtws.service;

import android.content.Context;
import android.util.Xml;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.android.util.NetWorkHelper;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class BaseService
{
  public static XmlPullParser getPullByURI(String paramString1, String paramString2, String paramString3, int paramInt1, int paramInt2)
    throws IOException, XmlPullParserException, TimeOutException, NotFoundNetWorkException
  {
    XmlPullParser localXmlPullParser = Xml.newPullParser();
    localXmlPullParser.setInput(getReaderByURI(paramString1, paramString2, paramString3, paramInt1, paramInt2));
    return localXmlPullParser;
  }

  public static Reader getReaderByURI(String paramString1, String paramString2, String paramString3, int paramInt1, int paramInt2)
    throws IOException, XmlPullParserException, TimeOutException, NotFoundNetWorkException
  {
    URLConnection localURLConnection = new URL(paramString1).openConnection();
    localURLConnection.setConnectTimeout(paramInt1);
    localURLConnection.setReadTimeout(paramInt2);
    localURLConnection.setDoInput(true);
    localURLConnection.setDoOutput(true);
    localURLConnection.setRequestProperty("Content-Type", "text/xml;charset=utf-8");
    localURLConnection.setRequestProperty("SOAPAction", paramString2);
    OutputStreamWriter localOutputStreamWriter = new OutputStreamWriter(localURLConnection.getOutputStream(), "UTF-8");
    localOutputStreamWriter.write(new String(paramString3.getBytes("UTF-8")));
    localOutputStreamWriter.flush();
    localOutputStreamWriter.close();
    return new InputStreamReader(localURLConnection.getInputStream(), "UTF-8");
  }

  public static String getStringBySoap(String paramString1, String paramString2, String paramString3, int paramInt1, int paramInt2, String paramString4)
    throws IOException, XmlPullParserException, TimeOutException, NotFoundNetWorkException
  {
    int i;
    Object localObject;
    try
    {
      XmlPullParser localXmlPullParser = getPullByURI(paramString1, paramString2, paramString3, paramInt1, paramInt2);
      i = localXmlPullParser.getEventType();
      localObject = null;
      break label79;
      while (true)
      {
        i = localXmlPullParser.next();
        break;
        if (localXmlPullParser.getName().equals(paramString4))
        {
          String str = localXmlPullParser.nextText();
          localObject = str;
        }
      }
    }
    catch (SocketTimeoutException localSocketTimeoutException)
    {
      throw new TimeOutException();
    }
    label79: if (i == 1)
      return localObject;
    switch (i)
    {
    default:
    case 2:
    }
  }

  public static String getStringBySoap(String paramString1, String paramString2, String paramString3, String paramString4, Context paramContext)
    throws IOException, XmlPullParserException, TimeOutException, NotFoundNetWorkException
  {
    if (!NetWorkHelper.isNetworkConnected(paramContext))
      throw new NotFoundNetWorkException();
    return getStringBySoap(paramString1, paramString2, paramString3, 15000, 60000, paramString4);
  }

  public static String getStringBySoap2(String paramString1, String paramString2, String paramString3, String paramString4, Context paramContext)
    throws IOException, XmlPullParserException, TimeOutException, NotFoundNetWorkException
  {
    if (!NetWorkHelper.isNetworkConnected(paramContext))
      throw new NotFoundNetWorkException();
    return getStringBySoap(paramString1, paramString2, paramString3, 15000, 15000, paramString4);
  }

  public static void throwTimeoutException()
    throws TimeOutException
  {
    throw new TimeOutException();
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.service.BaseService
 * JD-Core Version:    0.6.2
 */